package my.mall.admin.api.service

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
import my.mall.db.entity.GoodsCategory
import my.mall.db.mapper.GoodsCategoryMapper
import org.springframework.stereotype.Service

@Service
open class CategoryService(
    private val goodsCategoryMapper: GoodsCategoryMapper
) {

    open fun listByPid(parentId: Long?): List<GoodsCategory> {
        return goodsCategoryMapper.selectList(
            QueryWrapper<GoodsCategory>()
                .select(
                    GoodsCategory.ID,
                    GoodsCategory.CATEGORY_NAME,
                )
                .eq(GoodsCategory.PARENT_ID, parentId ?: 0L)
        )
    }
}
